Imports DocumentFormat.OpenXml.Spreadsheet
Imports FineUI
Imports Kimmo
Imports Microsoft.VisualBasic.CompilerServices
Imports System.Collections
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Data.SqlServerCe
Imports System.Diagnostics
Imports System.Runtime.CompilerServices

''' <summary>
''' This is the beginning of the Files business object to handle interaction between the user interface and the database.
''' </summary>
''' <remarks>This code is automatically generated by SystemBuilder.Show.</remarks>
Public Class clsFiles
    Public Property ID As Integer = 0
    Public Property ProjectID As Integer = 0
    Public Property ProjectName As String = ""
    Public Property TableId As Integer = 0
    Public Property TableName As String = ""
    Public Property BusinessObject As String = ""
    Public Property IsNew As Boolean = False
    Public Property DateFields As String = ""
    Public Property FieldsToUpdate As String = "ID,ProjectID,ProjectName,TableId,TableName,BusinessObject"

''' <summary>
''' The new method of the class to create new Files records.
''' </summary>
''' <remarks>This code is automatically generated by SystemBuilder.Show.</remarks>
Public Sub New()
    MyBase.New()
    Clear()
    IsNew = True
    DateFields = ""
    FieldsToUpdate = "ID,ProjectID,ProjectName,TableId,TableName,BusinessObject"
End Sub

''' <summary>
''' The Clear method clears all properties of the business object to defaults.
''' </summary>
''' <remarks>This code is automatically generated by SystemBuilder.Show.</remarks>
Public Sub Clear()
    ID = 0
    ProjectID = 0
    ProjectName = ""
    TableId = 0
    TableName = ""
    BusinessObject = ""
End Sub

''' <summary>
''' Delete Files records specified by a list of ID.
''' </summary>
''' <remarks>This code is automatically generated by SystemBuilder.Show.</remarks>
    Public Shared Sub Delete(ByRef Records As List(Of String))
        For Each rsStr As String In Records
            SQLCompact.RunQuery("delete from [Files] where ID = " & rsStr, True)
        Next
    End Sub


''' <summary>
''' Delete Files records meeting a particular field name criteria. In this case, ID
''' </summary>
''' <remarks>This code is automatically generated by SystemBuilder.Show.</remarks>
Public Shared Sub DeleteByID(ByVal intID As Integer)
    SQLCompact.RunQuery("Delete from [Files] where [ID] = " & intID)
End Sub

''' <summary>
''' Delete Files records from a list of particular field. In this case, ID
''' </summary>
''' <remarks>This code is automatically generated by SystemBuilder.Show.</remarks>
Public Shared Sub DeleteByListOfID(ByRef Records As List(Of String))
        For Each intID As String In Records
    SQLCompact.RunQuery("Delete from [Files] where [ID] = " & intID)
        Next
End Sub

''' <summary>
''' Delete Files records meeting a particular field name criteria. In this case, ProjectID
''' </summary>
''' <remarks>This code is automatically generated by SystemBuilder.Show.</remarks>
Public Shared Sub DeleteByProjectID(ByVal intProjectID As Integer)
    SQLCompact.RunQuery("Delete from [Files] where [ProjectID] = " & intProjectID)
End Sub

''' <summary>
''' Delete Files records from a list of particular field. In this case, ProjectID
''' </summary>
''' <remarks>This code is automatically generated by SystemBuilder.Show.</remarks>
Public Shared Sub DeleteByListOfProjectID(ByRef Records As List(Of String))
        For Each intProjectID As String In Records
    SQLCompact.RunQuery("Delete from [Files] where [ProjectID] = " & intProjectID)
        Next
End Sub

''' <summary>
''' Delete Files records meeting a particular field name criteria. In this case, ProjectName
''' </summary>
''' <remarks>This code is automatically generated by SystemBuilder.Show.</remarks>
Public Shared Sub DeleteByProjectName(ByVal strProjectName As String)
    SQLCompact.RunQuery("Delete from [Files] where [ProjectName] = '" & strProjectName & "'")
End Sub

''' <summary>
''' Delete Files records from a list of particular field. In this case, ProjectName
''' </summary>
''' <remarks>This code is automatically generated by SystemBuilder.Show.</remarks>
Public Shared Sub DeleteByListOfProjectName(ByRef Records As List(Of String))
        For Each strProjectName As String In Records
    SQLCompact.RunQuery("Delete from [Files] where [ProjectName] = '" & strProjectName & "'")
        Next
End Sub

''' <summary>
''' Delete Files records meeting a particular field name criteria. In this case, TableId
''' </summary>
''' <remarks>This code is automatically generated by SystemBuilder.Show.</remarks>
Public Shared Sub DeleteByTableId(ByVal intTableId As Integer)
    SQLCompact.RunQuery("Delete from [Files] where [TableId] = " & intTableId)
End Sub

''' <summary>
''' Delete Files records from a list of particular field. In this case, TableId
''' </summary>
''' <remarks>This code is automatically generated by SystemBuilder.Show.</remarks>
Public Shared Sub DeleteByListOfTableId(ByRef Records As List(Of String))
        For Each intTableId As String In Records
    SQLCompact.RunQuery("Delete from [Files] where [TableId] = " & intTableId)
        Next
End Sub

''' <summary>
''' Delete Files records meeting a particular field name criteria. In this case, TableName
''' </summary>
''' <remarks>This code is automatically generated by SystemBuilder.Show.</remarks>
Public Shared Sub DeleteByTableName(ByVal strTableName As String)
    SQLCompact.RunQuery("Delete from [Files] where [TableName] = '" & strTableName & "'")
End Sub

''' <summary>
''' Delete Files records from a list of particular field. In this case, TableName
''' </summary>
''' <remarks>This code is automatically generated by SystemBuilder.Show.</remarks>
Public Shared Sub DeleteByListOfTableName(ByRef Records As List(Of String))
        For Each strTableName As String In Records
    SQLCompact.RunQuery("Delete from [Files] where [TableName] = '" & strTableName & "'")
        Next
End Sub

''' <summary>
''' Delete Files records meeting a particular field name criteria. In this case, BusinessObject
''' </summary>
''' <remarks>This code is automatically generated by SystemBuilder.Show.</remarks>
Public Shared Sub DeleteByBusinessObject(ByVal strBusinessObject As String)
    SQLCompact.RunQuery("Delete from [Files] where [BusinessObject] = '" & strBusinessObject & "'")
End Sub

''' <summary>
''' Delete Files records from a list of particular field. In this case, BusinessObject
''' </summary>
''' <remarks>This code is automatically generated by SystemBuilder.Show.</remarks>
Public Shared Sub DeleteByListOfBusinessObject(ByRef Records As List(Of String))
        For Each strBusinessObject As String In Records
    SQLCompact.RunQuery("Delete from [Files] where [BusinessObject] = '" & strBusinessObject & "'")
        Next
End Sub

''' <summary>
''' Return a particular field based on another field. In this case return Files.ID based on Files.ID
''' </summary>
''' <remarks>This code is automatically generated by SystemBuilder.Show.</remarks>
Public Shared Function IDByID(ByVal intID As Integer) As Integer
    Dim mv As String = SQLCompact.RecordReadToMv("Files", "ID", intID, "ID", ";", "Integer")
    Return clsDL.MvField(mv, 1, ";")
End Function


''' <summary>
''' Return a particular field based on another field. In this case return Files.ID based on Files.ProjectID
''' </summary>
''' <remarks>This code is automatically generated by SystemBuilder.Show.</remarks>
Public Shared Function IDByProjectID(ByVal intProjectID As Integer) As Integer
    Dim mv As String = SQLCompact.RecordReadToMv("Files", "ProjectID", intProjectID, "ID", ";", "Integer")
    Return clsDL.MvField(mv, 1, ";")
End Function


''' <summary>
''' Return a particular field based on another field. In this case return Files.ProjectID based on Files.ID
''' </summary>
''' <remarks>This code is automatically generated by SystemBuilder.Show.</remarks>
Public Shared Function ProjectIDByID(ByVal intID As Integer) As Integer
    Dim mv As String = SQLCompact.RecordReadToMv("Files", "ID", intID, "ProjectID", ";", "Integer")
    Return clsDL.MvField(mv, 1, ";")
End Function


''' <summary>
''' Return a particular field based on another field. In this case return Files.ID based on Files.ProjectName
''' </summary>
''' <remarks>This code is automatically generated by SystemBuilder.Show.</remarks>
Public Shared Function IDByProjectName(ByVal strProjectName As String) As Integer
    Dim mv As String = SQLCompact.RecordReadToMv("Files", "ProjectName", strProjectName, "ID", ";", "String")
    Return clsDL.MvField(mv, 1, ";")
End Function


''' <summary>
''' Return a particular field based on another field. In this case return Files.ProjectName based on Files.ID
''' </summary>
''' <remarks>This code is automatically generated by SystemBuilder.Show.</remarks>
Public Shared Function ProjectNameByID(ByVal intID As Integer) As String
    Dim mv As String = SQLCompact.RecordReadToMv("Files", "ID", intID, "ProjectName", ";", "Integer")
    Return clsDL.MvField(mv, 1, ";")
End Function


''' <summary>
''' Return a particular field based on another field. In this case return Files.ID based on Files.TableId
''' </summary>
''' <remarks>This code is automatically generated by SystemBuilder.Show.</remarks>
Public Shared Function IDByTableId(ByVal intTableId As Integer) As Integer
    Dim mv As String = SQLCompact.RecordReadToMv("Files", "TableId", intTableId, "ID", ";", "Integer")
    Return clsDL.MvField(mv, 1, ";")
End Function


''' <summary>
''' Return a particular field based on another field. In this case return Files.TableId based on Files.ID
''' </summary>
''' <remarks>This code is automatically generated by SystemBuilder.Show.</remarks>
Public Shared Function TableIdByID(ByVal intID As Integer) As Integer
    Dim mv As String = SQLCompact.RecordReadToMv("Files", "ID", intID, "TableId", ";", "Integer")
    Return clsDL.MvField(mv, 1, ";")
End Function


''' <summary>
''' Return a particular field based on another field. In this case return Files.ID based on Files.TableName
''' </summary>
''' <remarks>This code is automatically generated by SystemBuilder.Show.</remarks>
Public Shared Function IDByTableName(ByVal strTableName As String) As Integer
    Dim mv As String = SQLCompact.RecordReadToMv("Files", "TableName", strTableName, "ID", ";", "String")
    Return clsDL.MvField(mv, 1, ";")
End Function


''' <summary>
''' Return a particular field based on another field. In this case return Files.TableName based on Files.ID
''' </summary>
''' <remarks>This code is automatically generated by SystemBuilder.Show.</remarks>
Public Shared Function TableNameByID(ByVal intID As Integer) As String
    Dim mv As String = SQLCompact.RecordReadToMv("Files", "ID", intID, "TableName", ";", "Integer")
    Return clsDL.MvField(mv, 1, ";")
End Function


''' <summary>
''' Return a particular field based on another field. In this case return Files.ID based on Files.BusinessObject
''' </summary>
''' <remarks>This code is automatically generated by SystemBuilder.Show.</remarks>
Public Shared Function IDByBusinessObject(ByVal strBusinessObject As String) As Integer
    Dim mv As String = SQLCompact.RecordReadToMv("Files", "BusinessObject", strBusinessObject, "ID", ";", "String")
    Return clsDL.MvField(mv, 1, ";")
End Function


''' <summary>
''' Return a particular field based on another field. In this case return Files.BusinessObject based on Files.ID
''' </summary>
''' <remarks>This code is automatically generated by SystemBuilder.Show.</remarks>
Public Shared Function BusinessObjectByID(ByVal intID As Integer) As String
    Dim mv As String = SQLCompact.RecordReadToMv("Files", "ID", intID, "BusinessObject", ";", "Integer")
    Return clsDL.MvField(mv, 1, ";")
End Function


''' <summary>
''' Return a particular field based on another field. In this case return Files.ProjectID based on Files.ProjectID
''' </summary>
''' <remarks>This code is automatically generated by SystemBuilder.Show.</remarks>
Public Shared Function ProjectIDByProjectID(ByVal intProjectID As Integer) As Integer
    Dim mv As String = SQLCompact.RecordReadToMv("Files", "ProjectID", intProjectID, "ProjectID", ";", "Integer")
    Return clsDL.MvField(mv, 1, ";")
End Function


''' <summary>
''' Return a particular field based on another field. In this case return Files.ProjectID based on Files.ProjectName
''' </summary>
''' <remarks>This code is automatically generated by SystemBuilder.Show.</remarks>
Public Shared Function ProjectIDByProjectName(ByVal strProjectName As String) As Integer
    Dim mv As String = SQLCompact.RecordReadToMv("Files", "ProjectName", strProjectName, "ProjectID", ";", "String")
    Return clsDL.MvField(mv, 1, ";")
End Function


''' <summary>
''' Return a particular field based on another field. In this case return Files.ProjectName based on Files.ProjectID
''' </summary>
''' <remarks>This code is automatically generated by SystemBuilder.Show.</remarks>
Public Shared Function ProjectNameByProjectID(ByVal intProjectID As Integer) As String
    Dim mv As String = SQLCompact.RecordReadToMv("Files", "ProjectID", intProjectID, "ProjectName", ";", "Integer")
    Return clsDL.MvField(mv, 1, ";")
End Function


''' <summary>
''' Return a particular field based on another field. In this case return Files.ProjectID based on Files.TableId
''' </summary>
''' <remarks>This code is automatically generated by SystemBuilder.Show.</remarks>
Public Shared Function ProjectIDByTableId(ByVal intTableId As Integer) As Integer
    Dim mv As String = SQLCompact.RecordReadToMv("Files", "TableId", intTableId, "ProjectID", ";", "Integer")
    Return clsDL.MvField(mv, 1, ";")
End Function


''' <summary>
''' Return a particular field based on another field. In this case return Files.TableId based on Files.ProjectID
''' </summary>
''' <remarks>This code is automatically generated by SystemBuilder.Show.</remarks>
Public Shared Function TableIdByProjectID(ByVal intProjectID As Integer) As Integer
    Dim mv As String = SQLCompact.RecordReadToMv("Files", "ProjectID", intProjectID, "TableId", ";", "Integer")
    Return clsDL.MvField(mv, 1, ";")
End Function


''' <summary>
''' Return a particular field based on another field. In this case return Files.ProjectID based on Files.TableName
''' </summary>
''' <remarks>This code is automatically generated by SystemBuilder.Show.</remarks>
Public Shared Function ProjectIDByTableName(ByVal strTableName As String) As Integer
    Dim mv As String = SQLCompact.RecordReadToMv("Files", "TableName", strTableName, "ProjectID", ";", "String")
    Return clsDL.MvField(mv, 1, ";")
End Function


''' <summary>
''' Return a particular field based on another field. In this case return Files.TableName based on Files.ProjectID
''' </summary>
''' <remarks>This code is automatically generated by SystemBuilder.Show.</remarks>
Public Shared Function TableNameByProjectID(ByVal intProjectID As Integer) As String
    Dim mv As String = SQLCompact.RecordReadToMv("Files", "ProjectID", intProjectID, "TableName", ";", "Integer")
    Return clsDL.MvField(mv, 1, ";")
End Function


''' <summary>
''' Return a particular field based on another field. In this case return Files.ProjectID based on Files.BusinessObject
''' </summary>
''' <remarks>This code is automatically generated by SystemBuilder.Show.</remarks>
Public Shared Function ProjectIDByBusinessObject(ByVal strBusinessObject As String) As Integer
    Dim mv As String = SQLCompact.RecordReadToMv("Files", "BusinessObject", strBusinessObject, "ProjectID", ";", "String")
    Return clsDL.MvField(mv, 1, ";")
End Function


''' <summary>
''' Return a particular field based on another field. In this case return Files.BusinessObject based on Files.ProjectID
''' </summary>
''' <remarks>This code is automatically generated by SystemBuilder.Show.</remarks>
Public Shared Function BusinessObjectByProjectID(ByVal intProjectID As Integer) As String
    Dim mv As String = SQLCompact.RecordReadToMv("Files", "ProjectID", intProjectID, "BusinessObject", ";", "Integer")
    Return clsDL.MvField(mv, 1, ";")
End Function


''' <summary>
''' Return a particular field based on another field. In this case return Files.ProjectName based on Files.ProjectName
''' </summary>
''' <remarks>This code is automatically generated by SystemBuilder.Show.</remarks>
Public Shared Function ProjectNameByProjectName(ByVal strProjectName As String) As String
    Dim mv As String = SQLCompact.RecordReadToMv("Files", "ProjectName", strProjectName, "ProjectName", ";", "String")
    Return clsDL.MvField(mv, 1, ";")
End Function


''' <summary>
''' Return a particular field based on another field. In this case return Files.ProjectName based on Files.TableId
''' </summary>
''' <remarks>This code is automatically generated by SystemBuilder.Show.</remarks>
Public Shared Function ProjectNameByTableId(ByVal intTableId As Integer) As String
    Dim mv As String = SQLCompact.RecordReadToMv("Files", "TableId", intTableId, "ProjectName", ";", "Integer")
    Return clsDL.MvField(mv, 1, ";")
End Function


''' <summary>
''' Return a particular field based on another field. In this case return Files.TableId based on Files.ProjectName
''' </summary>
''' <remarks>This code is automatically generated by SystemBuilder.Show.</remarks>
Public Shared Function TableIdByProjectName(ByVal strProjectName As String) As Integer
    Dim mv As String = SQLCompact.RecordReadToMv("Files", "ProjectName", strProjectName, "TableId", ";", "String")
    Return clsDL.MvField(mv, 1, ";")
End Function


''' <summary>
''' Return a particular field based on another field. In this case return Files.ProjectName based on Files.TableName
''' </summary>
''' <remarks>This code is automatically generated by SystemBuilder.Show.</remarks>
Public Shared Function ProjectNameByTableName(ByVal strTableName As String) As String
    Dim mv As String = SQLCompact.RecordReadToMv("Files", "TableName", strTableName, "ProjectName", ";", "String")
    Return clsDL.MvField(mv, 1, ";")
End Function


''' <summary>
''' Return a particular field based on another field. In this case return Files.TableName based on Files.ProjectName
''' </summary>
''' <remarks>This code is automatically generated by SystemBuilder.Show.</remarks>
Public Shared Function TableNameByProjectName(ByVal strProjectName As String) As String
    Dim mv As String = SQLCompact.RecordReadToMv("Files", "ProjectName", strProjectName, "TableName", ";", "String")
    Return clsDL.MvField(mv, 1, ";")
End Function


''' <summary>
''' Return a particular field based on another field. In this case return Files.ProjectName based on Files.BusinessObject
''' </summary>
''' <remarks>This code is automatically generated by SystemBuilder.Show.</remarks>
Public Shared Function ProjectNameByBusinessObject(ByVal strBusinessObject As String) As String
    Dim mv As String = SQLCompact.RecordReadToMv("Files", "BusinessObject", strBusinessObject, "ProjectName", ";", "String")
    Return clsDL.MvField(mv, 1, ";")
End Function


''' <summary>
''' Return a particular field based on another field. In this case return Files.BusinessObject based on Files.ProjectName
''' </summary>
''' <remarks>This code is automatically generated by SystemBuilder.Show.</remarks>
Public Shared Function BusinessObjectByProjectName(ByVal strProjectName As String) As String
    Dim mv As String = SQLCompact.RecordReadToMv("Files", "ProjectName", strProjectName, "BusinessObject", ";", "String")
    Return clsDL.MvField(mv, 1, ";")
End Function


''' <summary>
''' Return a particular field based on another field. In this case return Files.TableId based on Files.TableId
''' </summary>
''' <remarks>This code is automatically generated by SystemBuilder.Show.</remarks>
Public Shared Function TableIdByTableId(ByVal intTableId As Integer) As Integer
    Dim mv As String = SQLCompact.RecordReadToMv("Files", "TableId", intTableId, "TableId", ";", "Integer")
    Return clsDL.MvField(mv, 1, ";")
End Function


''' <summary>
''' Return a particular field based on another field. In this case return Files.TableId based on Files.TableName
''' </summary>
''' <remarks>This code is automatically generated by SystemBuilder.Show.</remarks>
Public Shared Function TableIdByTableName(ByVal strTableName As String) As Integer
    Dim mv As String = SQLCompact.RecordReadToMv("Files", "TableName", strTableName, "TableId", ";", "String")
    Return clsDL.MvField(mv, 1, ";")
End Function


''' <summary>
''' Return a particular field based on another field. In this case return Files.TableName based on Files.TableId
''' </summary>
''' <remarks>This code is automatically generated by SystemBuilder.Show.</remarks>
Public Shared Function TableNameByTableId(ByVal intTableId As Integer) As String
    Dim mv As String = SQLCompact.RecordReadToMv("Files", "TableId", intTableId, "TableName", ";", "Integer")
    Return clsDL.MvField(mv, 1, ";")
End Function


''' <summary>
''' Return a particular field based on another field. In this case return Files.TableId based on Files.BusinessObject
''' </summary>
''' <remarks>This code is automatically generated by SystemBuilder.Show.</remarks>
Public Shared Function TableIdByBusinessObject(ByVal strBusinessObject As String) As Integer
    Dim mv As String = SQLCompact.RecordReadToMv("Files", "BusinessObject", strBusinessObject, "TableId", ";", "String")
    Return clsDL.MvField(mv, 1, ";")
End Function


''' <summary>
''' Return a particular field based on another field. In this case return Files.BusinessObject based on Files.TableId
''' </summary>
''' <remarks>This code is automatically generated by SystemBuilder.Show.</remarks>
Public Shared Function BusinessObjectByTableId(ByVal intTableId As Integer) As String
    Dim mv As String = SQLCompact.RecordReadToMv("Files", "TableId", intTableId, "BusinessObject", ";", "Integer")
    Return clsDL.MvField(mv, 1, ";")
End Function


''' <summary>
''' Return a particular field based on another field. In this case return Files.TableName based on Files.TableName
''' </summary>
''' <remarks>This code is automatically generated by SystemBuilder.Show.</remarks>
Public Shared Function TableNameByTableName(ByVal strTableName As String) As String
    Dim mv As String = SQLCompact.RecordReadToMv("Files", "TableName", strTableName, "TableName", ";", "String")
    Return clsDL.MvField(mv, 1, ";")
End Function


''' <summary>
''' Return a particular field based on another field. In this case return Files.TableName based on Files.BusinessObject
''' </summary>
''' <remarks>This code is automatically generated by SystemBuilder.Show.</remarks>
Public Shared Function TableNameByBusinessObject(ByVal strBusinessObject As String) As String
    Dim mv As String = SQLCompact.RecordReadToMv("Files", "BusinessObject", strBusinessObject, "TableName", ";", "String")
    Return clsDL.MvField(mv, 1, ";")
End Function


''' <summary>
''' Return a particular field based on another field. In this case return Files.BusinessObject based on Files.TableName
''' </summary>
''' <remarks>This code is automatically generated by SystemBuilder.Show.</remarks>
Public Shared Function BusinessObjectByTableName(ByVal strTableName As String) As String
    Dim mv As String = SQLCompact.RecordReadToMv("Files", "TableName", strTableName, "BusinessObject", ";", "String")
    Return clsDL.MvField(mv, 1, ";")
End Function


''' <summary>
''' Return a particular field based on another field. In this case return Files.BusinessObject based on Files.BusinessObject
''' </summary>
''' <remarks>This code is automatically generated by SystemBuilder.Show.</remarks>
Public Shared Function BusinessObjectByBusinessObject(ByVal strBusinessObject As String) As String
    Dim mv As String = SQLCompact.RecordReadToMv("Files", "BusinessObject", strBusinessObject, "BusinessObject", ";", "String")
    Return clsDL.MvField(mv, 1, ";")
End Function


''' <summary>
''' Return the list of strings of a particular field. In this case Files.ID
''' </summary>
''' <remarks>This code is automatically generated by SystemBuilder.Show.</remarks>
    Public Shared Function IDList(Optional bAddNone As Boolean = False, Optional bIsDate As Boolean = False, Optional FldDelim As String = ";") As List(Of String)
        Dim strs As List(Of String) = SQLCompact.TableDistinctList("Files", "ID", "{0}", bAddNone, bIsDate, FldDelim)
        Return strs
    End Function

''' <summary>
''' Return the list of strings of a particular field. In this case Files.ProjectID
''' </summary>
''' <remarks>This code is automatically generated by SystemBuilder.Show.</remarks>
    Public Shared Function ProjectIDList(Optional bAddNone As Boolean = False, Optional bIsDate As Boolean = False, Optional FldDelim As String = ";") As List(Of String)
        Dim strs As List(Of String) = SQLCompact.TableDistinctList("Files", "ProjectID", "{0}", bAddNone, bIsDate, FldDelim)
        Return strs
    End Function

''' <summary>
''' Return the list of strings of a particular field. In this case Files.ProjectName
''' </summary>
''' <remarks>This code is automatically generated by SystemBuilder.Show.</remarks>
    Public Shared Function ProjectNameList(Optional bAddNone As Boolean = False, Optional bIsDate As Boolean = False, Optional FldDelim As String = ";") As List(Of String)
        Dim strs As List(Of String) = SQLCompact.TableDistinctList("Files", "ProjectName", "{0}", bAddNone, bIsDate, FldDelim)
        Return strs
    End Function

''' <summary>
''' Return the list of strings of a particular field. In this case Files.TableId
''' </summary>
''' <remarks>This code is automatically generated by SystemBuilder.Show.</remarks>
    Public Shared Function TableIdList(Optional bAddNone As Boolean = False, Optional bIsDate As Boolean = False, Optional FldDelim As String = ";") As List(Of String)
        Dim strs As List(Of String) = SQLCompact.TableDistinctList("Files", "TableId", "{0}", bAddNone, bIsDate, FldDelim)
        Return strs
    End Function

''' <summary>
''' Return the list of strings of a particular field. In this case Files.TableName
''' </summary>
''' <remarks>This code is automatically generated by SystemBuilder.Show.</remarks>
    Public Shared Function TableNameList(Optional bAddNone As Boolean = False, Optional bIsDate As Boolean = False, Optional FldDelim As String = ";") As List(Of String)
        Dim strs As List(Of String) = SQLCompact.TableDistinctList("Files", "TableName", "{0}", bAddNone, bIsDate, FldDelim)
        Return strs
    End Function

''' <summary>
''' Return the list of strings of a particular field. In this case Files.BusinessObject
''' </summary>
''' <remarks>This code is automatically generated by SystemBuilder.Show.</remarks>
    Public Shared Function BusinessObjectList(Optional bAddNone As Boolean = False, Optional bIsDate As Boolean = False, Optional FldDelim As String = ";") As List(Of String)
        Dim strs As List(Of String) = SQLCompact.TableDistinctList("Files", "BusinessObject", "{0}", bAddNone, bIsDate, FldDelim)
        Return strs
    End Function

''' <summary>
''' Return the total number of records in the table Files
''' </summary>
''' <remarks>This code is automatically generated by SystemBuilder.Show.</remarks>
Public Shared Function Count() As Integer
Dim nRecords As Integer = 0
Dim dt As DataTable = SQLCompact.OpenDataTable("select Count(ID) as Records from [Files]")
For Each dr As DataRow In dt.Rows
nRecords = Val(dr("Records").ToString)
Next
Return nRecords
End Function


''' <summary>
''' Return the total number of records with a particular value in a field. In this case Files.ID
''' </summary>
''' <remarks>This code is automatically generated by SystemBuilder.Show.</remarks>
Public Shared Function CountByID(ByVal intID As Integer) As Integer
Dim sQry As String = "Select Count(ID) As Records from [Files] where [ID] = " & intID
Dim dt As DataTable = SQLCompact.OpenDataTable(sQRY)
Dim nRecords as integer = 0
For Each dr As DataRow In dt.Rows
nRecords = Val(dr("Records").ToString)
Next
Return nRecords
End Function

''' <summary>
''' Return the total number of records with a particular value in a field. In this case Files.ProjectID
''' </summary>
''' <remarks>This code is automatically generated by SystemBuilder.Show.</remarks>
Public Shared Function CountByProjectID(ByVal intProjectID As Integer) As Integer
Dim sQry As String = "Select Count(ID) As Records from [Files] where [ProjectID] = " & intProjectID
Dim dt As DataTable = SQLCompact.OpenDataTable(sQRY)
Dim nRecords as integer = 0
For Each dr As DataRow In dt.Rows
nRecords = Val(dr("Records").ToString)
Next
Return nRecords
End Function

''' <summary>
''' Return the total number of records with a particular value in a field. In this case Files.ProjectName
''' </summary>
''' <remarks>This code is automatically generated by SystemBuilder.Show.</remarks>
Public Shared Function CountByProjectName(ByVal strProjectName As String) As Integer
Dim sQry As String = "Select Count(ID) As Records from [Files] where [ProjectName] = '" & strProjectName & "'"
Dim dt As DataTable = SQLCompact.OpenDataTable(sQRY)
Dim nRecords as integer = 0
For Each dr As DataRow In dt.Rows
nRecords = Val(dr("Records").ToString)
Next
Return nRecords
End Function

''' <summary>
''' Return the total number of records with a particular value in a field. In this case Files.TableId
''' </summary>
''' <remarks>This code is automatically generated by SystemBuilder.Show.</remarks>
Public Shared Function CountByTableId(ByVal intTableId As Integer) As Integer
Dim sQry As String = "Select Count(ID) As Records from [Files] where [TableId] = " & intTableId
Dim dt As DataTable = SQLCompact.OpenDataTable(sQRY)
Dim nRecords as integer = 0
For Each dr As DataRow In dt.Rows
nRecords = Val(dr("Records").ToString)
Next
Return nRecords
End Function

''' <summary>
''' Return the total number of records with a particular value in a field. In this case Files.TableName
''' </summary>
''' <remarks>This code is automatically generated by SystemBuilder.Show.</remarks>
Public Shared Function CountByTableName(ByVal strTableName As String) As Integer
Dim sQry As String = "Select Count(ID) As Records from [Files] where [TableName] = '" & strTableName & "'"
Dim dt As DataTable = SQLCompact.OpenDataTable(sQRY)
Dim nRecords as integer = 0
For Each dr As DataRow In dt.Rows
nRecords = Val(dr("Records").ToString)
Next
Return nRecords
End Function

''' <summary>
''' Return the total number of records with a particular value in a field. In this case Files.BusinessObject
''' </summary>
''' <remarks>This code is automatically generated by SystemBuilder.Show.</remarks>
Public Shared Function CountByBusinessObject(ByVal strBusinessObject As String) As Integer
Dim sQry As String = "Select Count(ID) As Records from [Files] where [BusinessObject] = '" & strBusinessObject & "'"
Dim dt As DataTable = SQLCompact.OpenDataTable(sQRY)
Dim nRecords as integer = 0
For Each dr As DataRow In dt.Rows
nRecords = Val(dr("Records").ToString)
Next
Return nRecords
End Function

''' <summary>
''' Return True or False if a particular Files record exists.
''' </summary>
''' <remarks>This code is automatically generated by SystemBuilder.Show.</remarks>
Public Shared Function Exists(ByVal intID as Integer) As Boolean
Dim flag As Boolean = SQLCompact.RecordExists("Files", "ID", intID, "Long")
Return flag
End Function


''' <summary>
''' Return True or False if a particular Files record exists based on ID
''' </summary>
''' <remarks>This code is automatically generated by SystemBuilder.Show.</remarks>
Public Shared Function ExistsByID(ByVal intID As Integer) As Boolean
Dim flag As Boolean = SQLCompact.RecordExists("Files", "ID", intID, "Integer")
Return flag
End Function

''' <summary>
''' Return True or False if a particular Files record exists based on ProjectID
''' </summary>
''' <remarks>This code is automatically generated by SystemBuilder.Show.</remarks>
Public Shared Function ExistsByProjectID(ByVal intProjectID As Integer) As Boolean
Dim flag As Boolean = SQLCompact.RecordExists("Files", "ProjectID", intProjectID, "Integer")
Return flag
End Function

''' <summary>
''' Return True or False if a particular Files record exists based on ProjectName
''' </summary>
''' <remarks>This code is automatically generated by SystemBuilder.Show.</remarks>
Public Shared Function ExistsByProjectName(ByVal strProjectName As String) As Boolean
Dim flag As Boolean = SQLCompact.RecordExists("Files", "ProjectName", strProjectName, "String")
Return flag
End Function

''' <summary>
''' Return True or False if a particular Files record exists based on TableId
''' </summary>
''' <remarks>This code is automatically generated by SystemBuilder.Show.</remarks>
Public Shared Function ExistsByTableId(ByVal intTableId As Integer) As Boolean
Dim flag As Boolean = SQLCompact.RecordExists("Files", "TableId", intTableId, "Integer")
Return flag
End Function

''' <summary>
''' Return True or False if a particular Files record exists based on TableName
''' </summary>
''' <remarks>This code is automatically generated by SystemBuilder.Show.</remarks>
Public Shared Function ExistsByTableName(ByVal strTableName As String) As Boolean
Dim flag As Boolean = SQLCompact.RecordExists("Files", "TableName", strTableName, "String")
Return flag
End Function

''' <summary>
''' Return True or False if a particular Files record exists based on BusinessObject
''' </summary>
''' <remarks>This code is automatically generated by SystemBuilder.Show.</remarks>
Public Shared Function ExistsByBusinessObject(ByVal strBusinessObject As String) As Boolean
Dim flag As Boolean = SQLCompact.RecordExists("Files", "BusinessObject", strBusinessObject, "String")
Return flag
End Function

''' <summary>
''' Read Method to read Files record from the database using a primarykey.
''' </summary>
''' <remarks>This code is automatically generated by SystemBuilder.Show.</remarks>
Public Sub Read(ByVal sID As String)
Try
Clear()
Dim nRead As New DataSet()
nRead = SQLCompact.RecordSeek("Files", "ID", sID, "*", "Integer")
Dim xCount As Boolean = nRead.Tables(0).Rows.Count - 1 <> -1
If xCount Then
Dim xRow As DataRow = nRead.Tables(0).Rows(0)
ID = Val(xRow("ID").ToString)
ProjectID = Val(xRow("ProjectID").ToString)
ProjectName = xRow("ProjectName").ToString
TableId = Val(xRow("TableId").ToString)
TableName = xRow("TableName").ToString
BusinessObject = xRow("BusinessObject").ToString
Me.IsNew = False
nRead.Dispose()
End If
Catch exc as Exception
Throw new Exception(exc.Message)
End Try
End Sub

''' <summary>
''' Save a Files record to the database using a primary key. This uses a property get and FieldsToUpdate, DateFields to update the database.
''' </summary>
''' <remarks>This code is automatically generated by SystemBuilder.Show.</remarks>
Public Sub Save()
Try
Dim strTable As String = "Files"
Dim strPriKey As String = "ID"
Dim CommText As String = ""
Dim xCommand As New SqlCeCommand
If ID = -1 Then
ID = SQLCompact.TableMaxValue(strTable, strPriKey, "") + 1
IsNew = True
Else
IsNew = False
End If
If FieldsToUpdate = "*" Then
FieldsToUpdate = SQLCompact.Table_FieldNames(strTable, False, ",")
End If
FieldsToUpdate = clsDL.MvRemoveDuplicates(Me.FieldsToUpdate, ",")
Dim strParameters As String = clsDL.MvPrefixBy(FieldsToUpdate, "@", ",")
If IsNew Then
CommText = clsDL.BuildInsertCommand(strTable, FieldsToUpdate, ",")
Else
CommText = clsDL.BuildUpdateCommand(strTable, FieldsToUpdate, strPriKey, ",")
End If
xCommand = SQLCompact.OpenCommand(CommText)
Dim spFields() As String = Split(FieldsToUpdate, ",")
With xCommand
.Parameters.Clear()
For each strField As String In spFields
Dim datePos As Integer = clsDL.MvSearch(DateFields, strField, ",")
If datePos > 0 Then
Dim strValue as string = clsDL.PropertyGet(Me, strField).ToString
.Parameters.AddWithValue("@" & strField, IIf((IsDate(strValue) = True), CDate(strValue), DBNull.Value))
Else
.Parameters.AddWithValue("@" & strField, clsDL.PropertyGet(Me, strField))
End If
Next
.ExecuteNonQuery()
End With
SQLCompact.Connection.Close()
xCommand.Dispose()
Catch exc as Exception
Throw new Exception(exc.Message)
End Try
End Sub

''' <summary>
''' This method builds up an editable grid based on selected records. The grid has Save, Clone and Delete buttons
''' </summary>
''' <remarks>This code is automatically generated by SystemBuilder.Show.</remarks>
Public Shared Sub ShowFiles(ByRef grdViews As FineUI.Grid, ByVal strFilter As String)
clsFineUI.Grid.Clear(grdViews, "", "")
clsFineUI.Grid.TableName = "Files"
clsFineUI.Grid.DataKeyNames = "ID"
clsFineUI.Grid.PageSize = 50
clsFineUI.Grid.AllowPaging = True
clsFineUI.Grid.AllowSorting = True
clsFineUI.Grid.LoadMask = False
clsFineUI.Grid.Title = "Files"
clsFineUI.Grid.ShowBorder = False
clsFineUI.Grid.ShowHeader = False
clsFineUI.Grid.EnableRowNumber = False
clsFineUI.Grid.AutoHeight = True
clsFineUI.Grid.AutoPostBack = False
clsFineUI.Grid.EnableCheckBoxSelect = True
clsFineUI.Grid.AutoWidth = True
clsFineUI.Grid.EnableAlternateRowColor = True
clsFineUI.Grid.EnableCollapse = False
clsFineUI.Grid.EnableMouseOverColor = True
clsFineUI.Grid.EnableMultiSelect = True
clsFineUI.Grid.EnableViewState = True
clsFineUI.Grid.EnableAjax = True
clsFineUI.Grid.ColumnLines = True
clsFineUI.Grid.ToolTipField = ""
clsFineUI.Grid.IsDatabasePaging = False
clsFineUI.Grid.ShowGridHeader = True
clsFineUI.Grid.EnableHeaderMenu = True
clsFineUI.Grid.EnableColumnHide = True
clsFineUI.Grid.AddColumn("ID", "ID", "{0}", "", "", False, "50", FineUi.TextAlign.Left, False)
clsFineUI.Grid.AddColumn("BusinessObject", "Business Object", "{0}", "", "", True, "300", FineUi.TextAlign.Left, False)
clsFineUI.Grid.AddSave()
clsFineUI.Grid.AddClone()
clsFineUI.Grid.AddDelete()
If Len(strFilter) > 0 Then clsFineUI.Grid.Filter = strFilter
clsFineUI.Grid.OrderBy = "ID"
clsFineUI.Grid.BuildSelectCommand()
clsFineUI.Grid.UseSQLCompact = True
clsFineUI.Grid.Update(Nothing)
End Sub

''' <summary>
''' Builds a readonly grid based on selected records, this grid has Edit, Clone, Delete, Like and Comment buttons.
''' </summary>
''' <remarks>This code is automatically generated by SystemBuilder.Show.</remarks>
Public Shared Sub ShowGrid(ByRef grdViews As FineUI.Grid, ByVal strFilter As String)
clsFineUI.Grid.Clear(grdViews, "", "")
clsFineUI.Grid.TableName = "Files"
clsFineUI.Grid.DataKeyNames = "ID"
clsFineUI.Grid.PageSize = 50
clsFineUI.Grid.AllowPaging = True
clsFineUI.Grid.AllowSorting = True
clsFineUI.Grid.LoadMask = False
clsFineUI.Grid.Title = "Files"
clsFineUI.Grid.ShowBorder = False
clsFineUI.Grid.ShowHeader = False
clsFineUI.Grid.EnableRowNumber = False
clsFineUI.Grid.AutoHeight = True
clsFineUI.Grid.AutoPostBack = False
clsFineUI.Grid.EnableCheckBoxSelect = True
clsFineUI.Grid.AutoWidth = True
clsFineUI.Grid.EnableAlternateRowColor = True
clsFineUI.Grid.EnableCollapse = False
clsFineUI.Grid.EnableMouseOverColor = True
clsFineUI.Grid.EnableMultiSelect = True
clsFineUI.Grid.EnableViewState = True
clsFineUI.Grid.EnableAjax = True
clsFineUI.Grid.ColumnLines = True
clsFineUI.Grid.ToolTipField = ""
clsFineUI.Grid.IsDatabasePaging = False
clsFineUI.Grid.ShowGridHeader = True
clsFineUI.Grid.EnableHeaderMenu = True
clsFineUI.Grid.EnableColumnHide = True
clsFineUI.Grid.AddColumn("ID", "ID", "{0}", "", "", False, "50", FineUi.TextAlign.Left, False)
clsFineUI.Grid.AddColumn("BusinessObject", "Business Object", "{0}", "", "", True, "300", FineUi.TextAlign.Left, False)
clsFineUI.Grid.AddEditCloneDelete()
clsFineUI.Grid.AddLikeComment()
If Len(strFilter) > 0 Then clsFineUI.Grid.Filter = strFilter
clsFineUI.Grid.OrderBy = "ID"
clsFineUI.Grid.BuildSelectCommand()
clsFineUI.Grid.UseSQLCompact = True
clsFineUI.Grid.Update(Nothing)
End Sub

''' <summary>
''' Import Files records from a csv file.
''' </summary>
''' <remarks>This code is automatically generated by SystemBuilder.Show.</remarks>
Public Shared Sub ImportFile(ByVal SourceFile As String, ByVal FileData As String)
Try
Dim spLines As String() = Strings.Split(FileData, vbCr & vbLf)
For each strLine As String In spLines
strLine = strLine.Trim
If Len(strLine) > 0 Then
Dim spLine As String() = Strings.Split(strLine, ",")
Dim clsNewFiles As New clsFiles
With clsNewFiles
.IsNew = True
.ID = -1
.Save
End With
End If
Next
Catch exc as exception
Throw new Exception(exc.message)
End Try
End Sub

''' <summary>
''' Define a blank Files record and save it in a database. This method is useful for a grid like interface.
''' </summary>
''' <remarks>This code is automatically generated by SystemBuilder.Show.</remarks>
Public Sub Blank()
Dim clsNewFiles As New clsFiles
clsNewFiles.Clear()
clsNewFiles.IsNew = True
clsNewFiles.ID = -1
clsNewFiles.Save
clsNewFiles.Dispose
End Sub
End Class

